<?php
$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
$oGoodscat = new Goodscat();
if($id <= 0){
	$list = $oGoodscat->get_category_list(0, '', 0, 0);
}else{
	$category_info = $oGoodscat->get_row($id, '*');
	$list = array($category_info['id'] => $category_info);
}

$prototypes = Prototype::get_prototypes();
echo '<pre>';
foreach($list as $key => $category_info){
	$row = array(
		'id' => $category_info['id'],
		'name' => $category_info['name'],
		'mark' => $category_info['mark'],
	);
	$category_info['attr'] = @unserialize($category_info['attr']);	// 属性
	$category_info['spec'] = @unserialize($category_info['spec']);	// 规格
	if(!empty($category_info['attr'])){
		$attr_arr = array();
		foreach($category_info['attr'] as $attr){
			$attr_arr[$attr['id']] = $prototypes['id_name_list'][$attr['id']];
		}
		$row['attr'] = $attr_arr;
	}

	if(!empty($category_info['spec'])){
		$spec_arr = array();
		foreach($category_info['spec'] as $spec){
			$spec_arr[$spec['id']] = $prototypes['id_name_list'][$spec['id']];
		}
		$row['spec'] = $spec_arr;
	}
	$list[$key] = $row;
}
echo cache_write('goods_categorys_export.php', $list);
print_r($list);
echo '</pre>';
exit;
?>